<?php

global $wp_version;

// Version and path to check version

$options = get_option('dkret3');
$checkscheme = @opendir(STYLESHEETPATH . "/schemes/");
if ($checkscheme && $options['scheme'] != 'standard')
	$scheme = get_bloginfo('stylesheet_directory') . '/schemes/' . $options['scheme'];
else
	$scheme = 'standard';

$themeData = get_theme_data(TEMPLATEPATH . '/style.css');
$installedVersion = trim($themeData['Version']);
if(!$installedVersion) {
	$installedVersion = "unknown";
}
define('DKRETSCHEME', $scheme);
define('THEMENAME', $themeData['Title']);
define('THEMEAUTHOR', $themeData['Author']);
define('THEMEURI', $themeData['URI']);
define('DKRETVERSION', $installedVersion);

$cur=(STYLESHEETPATH . '/style.css');
$localhost=strstr($cur, 'localhost');
$ct=get_theme_data($cur);

$installedVersion = trim($ct['Version']);
if(!$installedVersion) {
	$installedVersion = "unknown";
}

define('TEMPLATENAME', $ct['Title']);
define('TEMPLATEAUTHOR', $ct['Author']);
define('TEMPLATEURI', $ct['URI']);
define('TEMPLATEVERSION', $installedVersion);

/*
DKret2 helper functions
*/

global $wp_version;

function exist_widget_column ($column) {
  $widgetcolumns = wp_get_sidebars_widgets();
	switch($column) {
		case 'all' :
		  foreach ($widgetcolumns as $sidebar)
				if (!empty($sidebar)) return true;
    	break;
		case 'bottombars' :
  		if (($widgetcolumns['sidebar-5']) || ($widgetcolumns['sidebar-6']) || ($widgetcolumns['sidebar-7'])) return true;
			break;
		case 'Primary Sidebar' :
			if ($widgetcolumns['sidebar-1']) return true;
    	break;
		case 'Sidebar Column1' :
			if ($widgetcolumns['sidebar-2']) return true;
    	break;
		case 'Sidebar Column2' :
			if ($widgetcolumns['sidebar-3']) return true;
    	break;
		case 'Secondary Sidebar' :
			if ($widgetcolumns['sidebar-4']) return true;
    	break;
		case 'Bottombar Column1' :
			if ($widgetcolumns['sidebar-5']) return true;
    	break;
		case 'Bottombar Column2' :
			if ($widgetcolumns['sidebar-6']) return true;
    	break;
		case 'Bottombar Column3' :
			if ($widgetcolumns['sidebar-7']) return true;
    	break;
  }
	return false;
}

function findrandompicture() {
/* 
Original Plugin Name: K2-Picture upload
Original Plugin URI: http://ramlev.dk/wp-plugins/
Description: Change header picture.
Author: Hasse Ramlev Hansen <hasse@ramlev.dk>
Author URI: http://ramlev.dk
Version: 1.1.1
*/

	$picture_dir = @ dir(ABSPATH . '/wp-content/themes/' . get_template() . '/images/headers');
	if ($picture_dir)
	{
		while(($file = $picture_dir->read()) !== false)
		{
			if (!preg_match('|^\.+$|', $file) && !preg_match('|^CVS$|', $file) && preg_match('/\.(gif|jpg|png)$/i',$file))
			{
				$picture_files[] = $file;
			}
		}
	}
  $size = count($picture_files);
  return ($picture_files[rand(0, $size-1)]);
}

function dkret_inline_css() {
	$options = get_option('dkret3');
	if (DKRETSCHEME != 'standard')
		echo "\n\t<link rel=\"stylesheet\" type=\"text/css\" title=\"scheme\" media=\"screen\" href=\"". DKRETSCHEME .'" />';

	$picture = $options['headerimage'];
	if ($options['random_header'] == "1") {
		$picture = findrandompicture();
	}
	/* 
	check if picture is not the standard one and picture is not empty (otherwise right-click show graphic would open the header
	directory)
	*/
	if (($picture != "standard") && ($picture != "")) {
		echo "<style type=\"text/css\">#header { background: url('". get_bloginfo('template_url') ."/images/headers/$picture') repeat-x; }</style>";
	}
}

function dkret_addjs() {
	$options = get_option('dkret3');
	wp_enqueue_script('jquery');
	wp_enqueue_script('dkret-suckerfish', get_bloginfo('template_url') .'/js/dkret-suckerfish.js', array('jquery'), '3.1');
	if($options['previewcomment'] == 1 ) {
		wp_enqueue_script('dkret-commentpreview', get_bloginfo('template_url') .'/js/dkret-commentpreview.js', array('jquery'), '3.1');
	}
}

function dkret_widgets_init() {

	// WIDGETS
	register_sidebar(array(
		'name'=>'Primary Sidebar',
		'before_title' => "<h3 class='widgettitle'>",
		'after_title' => "</h3>",
	));

	register_sidebar(array(
		'name'=>'Sidebar Column1',
		'before_title' => "<h3 class='widgettitle'>",
		'after_title' => "</h3>",
	));
  
	register_sidebar(array(
		'name'=>'Sidebar Column2',
		'before_title' => "<h3 class='widgettitle'>",
		'after_title' => "</h3>",
	));

	register_sidebar(array(
		'name'=>'Secondary Sidebar',
		'before_title' => "<h3 class='widgettitle'>",
		'after_title' => "</h3>",
	));

	register_sidebar(array(
		'name'=>'Bottombar Column1',
		'before_title' => "<h3 class='widgettitle'>",
		'after_title' => "</h3>",
	));

	register_sidebar(array(
		'name'=>'Bottombar Column2',
		'before_title' => "<h3 class='widgettitle'>",
		'after_title' => "</h3>",
	));

	register_sidebar(array(
		'name'=>'Bottombar Column3',
		'before_title' => "<h3 class='widgettitle'>",
		'after_title' => "</h3>",
	));

	// now have a look for all available additional widgets and activate them
	$widgets_dir = @ dir(ABSPATH . '/wp-content/themes/' . get_template() . '/widgets');
	if ($widgets_dir)	{
		while(($widgetFile = $widgets_dir->read()) !== false) {
			if (!preg_match('|^\.+$|', $widgetFile) && preg_match('|\.php$|', $widgetFile))
				include(ABSPATH . '/wp-content/themes/' . get_template() . '/widgets/' . $widgetFile);
		}
	}

	// now have a look for all available additional widgets in the child  theme  and activate them
	$widgets_dir = @ dir(ABSPATH . '/wp-content/themes/' . get_stylesheet() . '/widgets');
	if ((TEMPLATENAME != THEMENAME) && ($widgets_dir)) {
		while(($widgetFile = $widgets_dir->read()) !== false) {
			if (!preg_match('|^\.+$|', $widgetFile) && preg_match('|\.php$|', $widgetFile))
				include(ABSPATH . '/wp-content/themes/' . get_stylesheet() . '/widgets/' . $widgetFile);
		}
	}
}

//save changed options
function dkretupdate() {
	if ( !empty($_POST) ) {
		$options = get_option('dkret3');
		if ( isset($_POST['scheme_file']) )
			$options['scheme'] = $_POST['scheme_file'];
		if ( isset($_POST['header_text']) )
			$options['blogtitle'] = '1';
		else
			$options['blogtitle'] = '0';
		if ( isset($_POST['header_rss']) )
			$options['rss'] = '1';
		else
			$options['rss'] = '0';
		if ( isset($_POST['show_subnavigation']) )
			$options['navigationlevel'] = $_POST['show_subnavigation'];
		if ( isset($_POST['nowreading']) )
			$options['nowreading'] = '1';
		else
			$options['nowreading'] = '0';
 		if ( isset($_POST['summary']) )
			$options['summary'] = '1';
		else
			$options['summary'] = '0';
		if ( isset($_POST['previewcomment']) )
			$options['previewcomment'] = '1';
		else
			$options['previewcomment'] = '0';
		if ( isset($_POST['cat']) )
			$options['gallery_cat_id'] = $_POST['cat'];
		if ( isset($_POST['gallerylink']) )
			$options['gallerylink'] = '1';
		else
			$options['gallerylink'] = '0';
		if ( isset($_POST['showgallery']) )
			$options['showgallery'] = '1';
		else
			$options['showgallery'] = '0';
		if ( isset($_POST['userandomfeature']) )
			$options['random_header'] = '1';
		else
			$options['random_header'] = '0';
		if ( isset($_POST['header_picture']) )
			$options['headerimage'] = $_POST['header_picture'];
		if ($_FILES['picture']['name'] != "" && $_FILES['picture']['size'] > 0) {
			$target_path =  ABSPATH . '/wp-content/themes/' . get_template() . '/images/headers/';
			move_uploaded_file($_FILES['picture']['tmp_name'], $target_path.$_FILES['picture']['name']);
			$options['headerimage'] = ($_FILES['picture']['name']);
		}
		update_option('dkret3', $options);
	}
}

// if we can't find dkret3 installed or installed version is older lets go ahead and install all the options that run dkret3.
$options = get_option('dkret3');
if ( (!$options) || ($options['version'] != DKRETVERSION) ) {
	dkret_switch();
	$options = array(
		'version'=>DKRETVERSION,
		'scheme'=>'standard',
		'blogtitle'=>'1',
		'rss'=>'0',
		'navigationlevel'=>'1',
		'nowreading'=>'1',
		'summary'=>'0',
		'previewcomment'=>'0',
		'random_header'=>'0',
		'headerimage'=>'standard',
		'gallery_cat_id'=>'-1',
		'gallerylink'=>'1',
		'showgallery'=>'0',
		);
	update_option('dkret3', $options);
}

function dkret_switch() {
	delete_option('dkret3');

	// delete options of the dkret Widgets
	// delete_option('widget_dkret_about');
	delete_option('widget_dkret_links');
	delete_option('widget_dkret_meta');
	delete_option('widget_dkret_randomquote');
	delete_option('widget_dkret_search');
	delete_option('widget_dkret_tagcloud');
	delete_option('widget_dkret_todo');
	delete_option('widget_dkret_icalevents');
	delete_option('widget_dkret_events');
	delete_option('widget_dkret_rsslinks');
	delete_option('widget_dkret_nowreading');
}

function add_theme_interface() {
	add_theme_page('Theme Settings', TEMPLATENAME . ' ' .__('Settings','dkret') , '8', 'functions', 'menu');
}

// localisation won't work without
load_theme_textdomain('dkret');

// let dkret add related posts
if (function_exists('st_related_posts')) {
  remove_filter('the_content','inlinePostTags');
  remove_filter('the_content','inlineRelatedPosts');
}

// add feed links to header
if (function_exists('automatic_feed_links'))
	automatic_feed_links();

// Filters so that things run smoothly
remove_action('wp_head', 'pagenavi_css');
add_action('wp_head','dkret_inline_css');

add_filter( 'archive_meta', 'wptexturize' );
add_filter( 'archive_meta', 'convert_smilies' );
add_filter( 'archive_meta', 'convert_chars' );
add_filter( 'archive_meta', 'wpautop' );

// add javascript to header
add_action('wp_head', 'dkret_addjs', 1);

// Add dkret widgets and properly unregister standard widgets
add_action( 'init', 'dkret_widgets_init' );

// delete  all options if theme is switched
//add_action('switch_theme', 'dkret_switch');

// Let's add the options page.
add_action('admin_menu', 'add_theme_interface');


/**
* Displays individual comments
* Uses the callback parameter for wp_list_comments
* Overwrites the default display of comments
*
* @param $comment The comment variable
* @param $args Array of arguments passed from wp_list_comments
* @param $depth What level the particular comment is
*/
function dkret_comments_callback($comment, $args, $depth) {
	$GLOBALS['comment_depth'] = $depth;
	$GLOBALS['comment'] = $comment;

?>
	<li <?php comment_class() ?> id="comment-<?php comment_ID() ?>">
		<div id="div-comment-<?php comment_ID() ?>">
			<div class="comment-author vcard">
					<?php $dkret_avatar_size = apply_filters( 'dkret_avatar_size', '40' ); // Filter for changing avatar size ?>
					<?php echo get_avatar( $comment, $dkret_avatar_size ); ?>
					<?php echo get_comment_author_link() ?>
			</div>
			<div class="comment-meta commentmetadata">
				<a href="#comment-<?php comment_ID() ?>" title=""><?php printf(__('%1$s at %2$s','dkret'), get_comment_date(),  get_comment_time()) ?></a>
				<?php
					$max_depth = get_option('thread_comments_depth');
					echo comment_reply_link(array(
						'add_below' => 'div-comment',
						'reply_text' => __('Reply','dkret'), 
						'login_text' => __('Log in to reply.','dkret'),
						'depth' => $depth,
						'max_depth' => $max_depth, 
						'before' => '<span class="separator">|</span> <span class="comment-reply-link">', 
						'after' => '</span>'
					));
				?>
				<?php if (!class_exists('WPrapAjaxEditComments')) edit_comment_link(__('Edit', 'dkret'), ' <span class="meta-sep">|</span> <span class="edit-link">', '</span>') ?>
			</div>
<?php if ($comment->comment_approved == '0') : ?> 
			<span class="unapproved"><?php _e('Your comment is awaiting moderation.', 'dkret') ?></span>
<?php endif; ?>
			<?php echo apply_filters('comment_text', get_comment_text()) ?>

		</div>
<?php
}

/**
* Ends the display of individual comments
* Uses the callback parameter for wp_list_comments
* Needs to be used in conjunction with dkret_comments_callback
* Not needed but used just in case something is changed
*
* @since 0.2.3
*/
function dkret_comments_end_callback() {
	echo "</li>";
}

/**
* Displays individual comments
* Uses the callback parameter for wp_list_comments
* Overwrites the default display of comments
*
* @param $comment The comment variable
* @param $args Array of arguments passed from wp_list_comments
* @param $depth What level the particular comment is
*/
function dkret_guestbook_callback($comment, $args, $depth) {
	$GLOBALS['comment_depth'] = $depth;
	$GLOBALS['comment'] = $comment;

?>
	<li <?php comment_class() ?> id="comment-<?php comment_ID() ?>">
		<div id="div-comment-<?php comment_ID() ?>">
			<div class="comment-author vcard">
					<?php $dkret_avatar_size = apply_filters( 'dkret_avatar_size', '40' ); // Filter for changing avatar size ?>
					<?php echo get_avatar( $comment, $dkret_avatar_size ); ?>
					<?php echo get_comment_author_link() ?>
			</div>
			<div class="comment-meta commentmetadata">
				<a href="#comment-<?php comment_ID() ?>" title=""><?php printf(__('%1$s at %2$s','dkret'), get_comment_date(),  get_comment_time()) ?></a>
				<?php
					$max_depth = get_option('thread_comments_depth');
					echo comment_reply_link(array(
						'add_below' => 'div-comment',
						'reply_text' => __('Reply','dkret'), 
						'login_text' => __('Log in to reply.','dkret'),
						'depth' => $depth,
						'max_depth' => $max_depth, 
						'before' => '<span class="separator">|</span> <span class="comment-reply-link">', 
						'after' => '</span>'
					));
				?>
				<?php if (!class_exists('WPrapAjaxEditComments')) edit_comment_link(__('Edit', 'dkret'), ' <span class="meta-sep">|</span> <span class="edit-link">', '</span>') ?>
			</div>
<?php if ($comment->comment_approved == '0') : ?> 
			<span class="unapproved"><?php _e('Your guestbook entry is awaiting moderation.', 'dkret') ?></span>
<?php endif; ?>
			<?php echo apply_filters('comment_text', get_comment_text()) ?>

		</div>
<?php
}

/**
* Ends the display of individual guestbook comments
* Uses the callback parameter for wp_list_comments
* Needs to be used in conjunction with dkret_comments_callback
* Not needed but used just in case something is changed
*
* @since 0.2.3
*/
function dkret_guestbook_end_callback() {
	echo "</li>";
}

// dkret options page
function menu() { ?>

	<div class="wrap">

		<h2><?php printf(__('%s theme settings','dkret'), TEMPLATENAME) ?></h2>

<?php global $wp_version;
	$options=get_option('dkret3');
	
	if (isset($_POST['Submit'])) {
?>

	<div id="mesage" class="updated fade">
		<p><strong><?php _e('Settings saved','dkret'); ?></strong></p>
	</div>

<?php } ?>

			<h3><?php printf(__('About %s','dkret'), TEMPLATENAME) ?></h3>

				<table cellspacing="0" class="widefat post fixed">

					<tr>
						<th style="width: 180px;"><?php _e('Developed by:','dkret') ?></th>
						<td><?php echo TEMPLATEAUTHOR ?></td>
					</tr>
					<tr>
						<th><?php _e('Theme Version:','dkret'); ?></th>
						<td><?php echo TEMPLATEVERSION ?></td>
					</tr>
					<tr>
						<th><?php _e('Theme Support:','dkret'); ?></th>
						<td><a href="<?php echo TEMPLATEURI ?>" title="<?php _e('Get support for this theme','dkret'); ?>"><?php printf(__('Visit the %s theme page','dkret'), TEMPLATENAME) ?></a></td>
					</tr>
<?php if (THEMENAME != TEMPLATENAME) { ?>
					<tr>
						<th><?php _e('Child theme based on:','dkret') ?></th>
						<td><a href="<?php THEMEURI ?>" title="<?php _e('Download the dkret parent theme','dkret'); ?>"><?php echo THEMENAME ?></a></td>
					</tr>
<?php } ?>	

				</table>

			<form name="dofollow" action="" method="post" enctype="multipart/form-data">
				<input type="hidden" name="action" value="<?php dkretupdate(); ?>" />
				<input type="hidden" name="page_options" value="'dofollow_timeout'" />

<?php
	$options=get_option('dkret3');
	global $checkscheme;
	if ($checkscheme) {
?>
				<h3><?php _e('Blog appearance','dkret'); ?></h3>

				<table cellspacing="0" class="widefat post fixed">
					<tbody>
						<tr valign="top">
							<th style="width: 230px;" scope="row"><?php _e('Schemes','dkret'); ?></th>
							<td>
								<select name="scheme_file" id="scheme_file" style="width: 200px;">
								<option value="<?php echo $options['scheme'] ?>"><?php if ($options['scheme'] == 'standard') { _e('Standard Scheme','dkret'); } else { echo $options['scheme']; } ?></option>
								<option value=""> ------ </option>
								<option value="standard"><?php _e('Use Standard Design','dkret') ?></option>
    
<?php
	$scheme_dir = @ dir(ABSPATH . '/wp-content/themes/' . get_option('stylesheet') . '/schemes');

	if ($scheme_dir) {
		while(($file = $scheme_dir->read()) !== false) {
			if (!preg_match('|^\.+$|', $file) && preg_match('|\.css$|', $file)) 
				$scheme_files[] = $file;
			}
		}
		if ($scheme_dir || $scheme_files) {
			foreach($scheme_files as $scheme_file) {
				echo '<option value="' . $scheme_file . '">' . $scheme_file . '</option>';
			}
		} 
		echo '</select>'; ?>
		
								<p><?php _e("Schemes are CSS files that allow you to visually customize your blog, without ever touching the themes core files.<br />Read the documentation for further information.",'dkret'); ?></p>

							</td>
						</tr>
<?php 
	}
?>

				<script type="text/javascript">
					var blogadress = "<?php echo get_template(); ?>";
					function updateHeader(sel) {
						if (sel.options[sel.selectedIndex].value == "standard") {
							document.header.src = "../wp-content/themes/" + blogadress + "/images/bg_header_standard.jpg";
						}	else {
							document.header.src = "../wp-content/themes/" + blogadress + "/images/headers/" + sel.options[sel.selectedIndex].value;
						}
					}
				</script>


						<tr valign="top">
							<th scope="row"><?php _e('Upload Images','dkret'); ?></th>
							<td>
								<label for="picture">
<?php
	$picture_dir = ABSPATH . '/wp-content/themes/' . get_template() . '/images/headers';
	// check for permission settings, Safe mode limitations are not taken into account. 
	if ( !is_writeable($picture_dir ) ) {
		$picture_dir = '/' . get_template() . '/images/headers';
		printf(__('Folder <strong>%1$s</strong> is not writable. Upload wont work.', 'dkret'), $picture_dir);
	} else {
?>
									<input id="picture" size="30" type="file" name="picture" /><br />
									<?php _e("Press <strong>'Save changes'</strong> at the bottom to upload the image.",'dkret') ?>
<?php 
	}
?>
								</label>
							</td>
						</tr>
						<tr>
							<th scope="row"><?php _e('Select Header','dkret'); ?></th>
							<td>
								<select style="width: 200px;" name="header_picture" onchange="updateHeader( this )">
									<option value="<?php echo $options['headerimage'] ?>"><?php if ($options['headerimage'] == 'standard') { _e('Standard Header Image','dkret'); } else { echo $options['headerimage']; } ?></option>
									<option value=""> ------ </option>
									<option value="standard"><?php _e('Standard Header Image','dkret'); ?></option>
<?php
	$picture_dir = @ dir(ABSPATH . '/wp-content/themes/' . get_template() . '/images/headers');
	if ($picture_dir)	{
		while(($file = $picture_dir->read()) !== false)	{
			if (!preg_match('|^\.+$|', $file) && !preg_match('|^CVS$|', $file) && preg_match('/\.(gif|jpg|png)$/i',$file))	{
				$picture_files[] = $file;
			}
		}
		if ($picture_dir && $picture_files)	{
			foreach ($picture_files as $picture_file) {
				echo "<option value=\"".$picture_file."\">".$picture_file."</option>";
			}
		}
		else {
			$options['headerimage'] == 'standard';
			update_option('dkret3', $options);
		}
	}
?>
								</select>							
								<br/>
<?php
	global $wpdb;
	$picname = $options['headerimage'];

	if ($picname != 'standard')	{
		$picture_title = $picname;
	}	else {
		$picture_title = __('Standard Header Image','dkret');
	}
	if ($picname != 'standard') {
		$pic = '../wp-content/themes/' . get_template() . '/images/headers/'.$picture_title;
	}	else {
		$pic = '../wp-content/themes/' . get_template() . '/images/bg_header_standard.jpg';
	}
	echo ('<img name="header" src="'.$pic.'" alt="" width="200"></img>');
?>
							</td>
						</tr>

						<tr valign="top">
							<th scope="row"><?php _e('Random Header','dkret'); ?></th>
							<td>
								<label for="userandomfeature">
									<input id="userandomfeature" type="checkbox" name="userandomfeature" value="1" <?php checked('1', $options['random_header']) ?> />
									<?php _e('Show Random Header Picture','dkret'); ?>
								</label>
							</td>
						</tr>
						<tr valign="top">
							<th scope="row"><?php _e('Title','dkret'); ?></th>
							<td>
								<label for="show_title">
									<input name="header_text" id="show_title" type="checkbox" value="1" <?php checked('1', $options['blogtitle']) ?> />
									<?php _e('Show Title','dkret') ?>
								</label>
							</td>
						</tr>
						<tr valign="top">
							<th scope="row"><?php _e('RSS-Links','dkret'); ?></th>
							<td>
								<label for="show_rss">
									<input name="header_rss" id="show_rss" type="checkbox" value="1" <?php checked('1', $options['rss']) ?> />
									<?php _e('Show RSS-Links','dkret') ?>
								</label>
							</td>
						</tr>
<?php if (function_exists ('library_url')) { ?>
						<tr valign="top">
							<th scope="row"><?php _e('Now Reading Link','dkret'); ?></th>
							<td>
								<label for="nowreading">
									<input name="nowreading" id="nowreading" type="checkbox" value="1" <?php checked('1', $options['nowreading']) ?> />
									<?php _e('Show Now Reading Link','dkret') ?>
								</label>
							</td>
						</tr>
<?php } ?>
						<tr valign="top">
							<th scope="row"><?php _e('Levels of Navigation','dkret'); ?></th>
							<td>						
								<select style="width: 200px;" name="show_subnavigation" id="show_subnavigation">
									<option value="<?php echo $options['navigationlevel'] ?>">
<?php
	$level = $options['navigationlevel'];
	$messages[0] = __('Hide top navigation', 'dkret');
	$messages[1] = __('Show top-level links only', 'dkret');
	$messages[2] = __('Show first sub-level', 'dkret');
	$messages[3] = __('Show second sub-level', 'dkret');
	$messages[4] = __('Show third sub-level', 'dkret');
	echo $messages[$level]; 
?>
									</option>
									<option value=""> ------ </option>
									<option value="0"><?php echo $messages[0] ?></option>
									<option value="1"><?php echo $messages[1] ?></option>
									<option value="2"><?php echo $messages[2] ?></option>
									<option value="3"><?php echo $messages[3] ?></option>
									<option value="4"><?php echo $messages[4] ?></option>
								</select>
								<br/>
								<?php _e("Choose number of levels you want to show in your top navigation.<br /><b>Add Pages Widget so everybody (even without javascript) can access your site</b>.",'dkret'); ?>
							</td>
						</tr>

						<tr valign="top">
							<th scope="row"><?php _e('Summary','dkret'); ?></th>
							<td>
								<label for="summary">
									<input id="summary" type="checkbox" name="summary" value="1" <?php checked('1', $options['summary']) ?> />
									<?php _e('Show search, author, category, tags and archive pages as Summary','dkret'); ?>
								</label>
							</td>
						</tr>

						<tr valign="top">
							<th scope="row"><?php _e('Preview Comments','dkret'); ?></th>
							<td>
								<label for="previewcomment">
									<input id="previewcomment" type="checkbox" name="previewcomment" value="1" <?php checked('1', $options['previewcomment']) ?> />
									<?php _e('Show Comment Preview','dkret'); ?>
								</label>
							</td>
						</tr>
					</tbody>
				</table>

				<h3><?php _e('Gallery','dkret'); ?></h3>
				<p><?php _e("Dkret supports the gallery function of Wordpress extensively. Dkret shows galleries if you set a category for your gallery posts.",'dkret') ?></p>

				<table cellspacing="0" class="widefat post fixed">
					<tbody>
						<tr valign="top">
							<th style="width: 230px;" scope="row"><?php _e('Gallery category','dkret'); ?></th>
							<td>
								<?php wp_dropdown_categories('hide_empty=0&selected='. $options['gallery_cat_id'] .'&show_option_none='. __('No Gallery', 'dkret') ); ?>
							</td>
						</tr>
						<tr valign="top">
							<th scope="row"><?php _e('Gallery Link','dkret'); ?></th>
							<td>
								<label for="gallerylink">
									<input id="gallerylink" type="checkbox" name="gallerylink" value="1" <?php checked('1', $options['gallerylink']) ?> />
									<?php _e('Show Gallery Link','dkret'); ?>
								</label>
							</td>
						</tr>
						<tr valign="top">
							<th scope="row"><?php _e('Gallerie View on blog home','dkret'); ?></th>
							<td>
								<label for="showgallery">
									<input id="showgallery" type="checkbox" name="showgallery" value="1" <?php checked('1', $options['showgallery']) ?> />
									<?php _e('Style gallery categorized posts different','dkret'); ?>
								</label>
							</td>
						</tr>
					</tbody>
				</table>
	
				<p class="submit"><input type="submit" name="Submit" value="<?php _e('Save Changes','dkret') ?> &raquo;" /></p>

			</form>

	</div><!-- .wrap -->

<?php } //  end of dkrets options menu
?>